<%@ page language="java" pageEncoding="utf-8" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<%
    String path = request.getContextPath();
    String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort()
            + path + "/";
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
    <base href="<%=basePath%>"/>
    <meta http-equiv="pragma" content="no-cache"/>
    <meta http-equiv="cache-control" content="no-cache"/>
    <meta http-equiv="expires" content="0"/>
    <meta http-equiv="keywords" content="keyword1,keyword2,keyword3"/>
    <meta http-equiv="description" content="This is my page"/>
    <title>添加主题--管理后台</title>
    <link href="../../../static/css/admin.css" rel="stylesheet" type="text/css"/>
    <script type="text/javascript" src="../../../static/js/jquery-1.12.4.min.js"></script>
    <script type="text/javascript" src="../../../static/js/layer.js"></script>
    <%--    <script type="text/javascript" src="../static/js/admin.js"></script>--%>
    <script type="text/javascript" src="../../../static/js/admin.js"></script>
</head>
<body>
<div id="header">
    <div id="welcome">欢迎使用新闻管理系统！</div>
    <div id="nav">
        <div id="logo"><img src="../../../static/images/logo.jpg" alt="新闻中国"/></div>
        <div id="a_b01"><img src="../../../static/images/a_b01.gif" alt=""/></div>
    </div>
</div>
<div id="admin_bar">
    <div id="beforelogin">
        <label> 登录名 </label>
        <input type="text" id="adminname" value="admin" class="login_input"/>
        <label> 密&#160;&#160;码 </label>
        <input type="password" id="adminpwd" value="admin" class="login_input"/>
        <input type="button" class="login_sub" value="登录" onclick="login()"/>
    </div>
    <div id="loginok" style="display: none">
        欢迎：<input id="username" value="" style="border-style: none" readonly></input>

        <input type="button" onclick="loginOut()" value="退出登陆"/>
    </div>
<%--    <button  style="float: right" onclick="toIndex()">返回首页</button>--%>
</div>

<div id="main">
    <%@ include file="./console_element/left.html" %>

        <div id="adminNews" style="float: left;width: 80%">
        </div>
</div>
<div id="footer">
    <%@ include file="./console_element/bottom.html" %>
</div>
</body>
<script>
    if (window.sessionStorage.getItem("username") != null) {
        document.getElementById("beforelogin").style.display = "none";
        document.getElementById("loginok").style.display = "block";
        console.log(window.sessionStorage.getItem("username"))
        document.getElementById("username").value = window.sessionStorage.getItem("username")
    }
    var globalPageNum = window.sessionStorage.getItem("globalPageNum")
    if (globalPageNum == null) {
        globalPageNum = 1
    }
    var globalTid = window.sessionStorage.getItem("globalTid")
    if (globalTid == null) {
        globalTid = 0
    }
    var globalKey = window.sessionStorage.getItem("globalKey")
    if (globalKey != null) {
        let a = globalKey.toString()
        console.log(a)
        document.getElementById("mysearch").value = globalKey
        // $('#mysearch').attr("value",globalKey);
    }
    $(function () {
        $.ajax({
            url: "news/getAdminAllNews",
            method: "GET",
            data: {
                "pageNum": globalPageNum,
                "tid": globalTid,
                "keywords": globalKey
            },
            dataType: "html",
            success: function (response) {
                document.getElementById("adminNews").innerHTML = response
            }
        })
    })
    var imageInput = document.getElementById("imageInput");
    var preview = document.getElementById("preview");
    $(imageInput).on("change", function (event) {
        var file = event.target.files[0];
        var reader = new FileReader();

        reader.onload = function (e) {
            preview.style.backgroundImage = "url(" + e.target.result + ")";
        };

        reader.readAsDataURL(file);
    });


</script>
</html>
